package com.appkubes.mall.restful.application.system.basic.dao;

import com.appkubes.mall.core.dao.BaseMallSystemDao;
import com.appkubes.mall.core.entity.MallSystem;
import com.appkubes.mall.restful.application.system.basic.model.PayResult;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface SystemDao extends BaseMallSystemDao {

    @Select({"SELECT * FROM mall_system WHERE platform='wechat'  ORDER BY `sort` DESC LIMIT 1"})
    MallSystem getCurr();

    @Select({"SELECT * FROM mall_system WHERE platform='wechat' AND app_key=#{appKey} ORDER BY `sort` DESC LIMIT 1"})
    MallSystem getAliCur(@Param("appKey") String appKey);

    @Select({"SELECT * FROM mall_system WHERE platform='wechat'  AND appid =#{appid} ORDER BY `sort` DESC LIMIT 1"})
    MallSystem getSystemInfoByAppid(@Param("appid") String appid);

    @Select({"SELECT * FROM mall_system  where ${queryStr}"})
    List<MallSystem> getList(@Param("queryStr") String queryStr);

    @Select({"SELECT system_key, pt_name, platform, appid, mchid, index, ali_alipayrsaPublicKey" +
            " FROM mall_system WHERE app_key=#{appKey} AND name like '%#{key}%'"})
    List<PayResult> getPayList(@Param("appKey") String appKey, @Param("key") String key);
}